﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace BabyShop.CP
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                Response.Redirect("default.aspx");
            }
        }

        protected void btnlogin_Click(object sender, EventArgs e)
        {           
            string username = txtUsername.Text.Trim();
            string password = txtPassword.Text.Trim();                        
            if (FormsAuthentication.Authenticate(username,password))
            {
                //FormsAuthentication.RedirectFromLoginPage(username, true);
                FormsAuthentication.SetAuthCookie(username, true);
                Response.Redirect("default.aspx");
            }
            else
            {
                txtBadCredential.Visible = true;
            }
        } 
    }
}